package com.ch.playandroid.adapter

import com.alibaba.android.arouter.launcher.ARouter
import com.ch.common.constant.ConstantValue
import com.ch.playandroid.bean.DataBean
import com.chad.library.adapter.base.BaseQuickAdapter

/**
 * 传统写Recycle写法，配合ArticleViewHolder----对应（首页--文章列表）
 *
 * */
class ArticleAdapter(layoutResId: Int, dataList: List<DataBean>) :
    BaseQuickAdapter<DataBean, ArticleViewHolder>(layoutResId, dataList as MutableList<DataBean>) {
    override fun convert(holder: ArticleViewHolder, item: DataBean) {
        item?.run {
            holder.articleTitleTv.text = title
            holder.chapterNameTv.text = chapterName
            holder.shareDataTv.text = niceShareDate
            holder.shareUserTv.text = shareUser

            holder.itemView.setOnClickListener {
                ARouter.getInstance().build(ConstantValue.PATH_WEB_VIEW)
                    .withString(ConstantValue.ACTION_KEY_TITLE, title)
                    .withString(ConstantValue.ACTION_KEY_URL, link)
                    .navigation()
            }
        }

    }
}